package com.neusoft.controller;

import com.neusoft.domain.PageResult;
import com.neusoft.domain.Result;
import com.neusoft.service.FoodCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.neusoft.domain.FoodCategory;
@RestController
@RequestMapping("/foodCategory")
public class FoodCategoryController {
    @Autowired
    private FoodCategoryService foodCategoryService;
    @GetMapping("/pageSelectFoodCategory")
    public Result pageSelectFoodCategory(Integer pageNum,Integer pageSize,String categoryName,Integer shopId){
        PageResult<FoodCategory> foodCategoryPageResult = foodCategoryService.pageSelectFoodCategory(pageNum, pageSize, categoryName,shopId);
        return Result.success(foodCategoryPageResult);
    }
    @PostMapping("/saveCategory")
    public Result saveCategory(@RequestBody FoodCategory foodCategory){
        foodCategoryService.saveCategory(foodCategory);
        return Result.success();
    }
    @PutMapping("/updateCategory")
    public Result updateCategory(@RequestBody FoodCategory foodCategory){
        foodCategoryService.updateCategory(foodCategory);
        return Result.success();
    }
    @DeleteMapping("/deleteCategory/{categoryId}")
    public Result deleteCategory(@PathVariable Integer categoryId){
        foodCategoryService.deleteCategory(categoryId);
        return Result.success();
    }


}
